﻿@model MerchantTribe.Commerce.Orders.Order

@Html.Partial("~/areas/account/views/shared/_OrderDownloads.cshtml", Model)
<table cellspacing="0" cellpadding="3" width="100%">
    <tr>
        <td width="67%" colspan="2">
            <h1>Order @Model.OrderNumber</h1>                            
        </td>
        <td width="33%" valign="top" align="right">
            @Model.FullOrderStatusDescription()                        
        </td>
    </tr>
    <tr>
        <td valign="top">
            <span class="lightlabel">Bill To:</span><br />
            @Html.Raw(Model.BillingAddress.ToHtmlString())            
        </td>
        <td valign="top">            
            <span class="lightlabel">Ship To:</span><br />
            @Html.Raw(Model.ShippingAddress.ToHtmlString())            
        </td>
        <td>&nbsp;</td>
    </tr>
    <tr>
        <td colspan="3">@Html.Partial("_ViewOrderItems", Model.Items)</td>
    </tr>
    <tr>
        <td valign="top">
            @if (Model.Instructions.Trim().Length > 0)
            {
                <em>Customer's Instructions:</em><br />
                @Model.Instructions
            }
            @if (Model.Coupons.Count > 0)
            {
                <em>Codes Used:</em><br />    
                foreach (var coupon in Model.Coupons)
                {
                     @coupon.CouponCode<br />
                }
            }                        
        </td>
        <td valign="top" colspan="2" align="right">
            @Html.Raw(Model.TotalsAsTable())            
        </td>
    </tr>
    <tr>
        <td colspan="3">
            <div style="height: 20px;">
            </div>
        </td>
    </tr>
    <tr runat="Server" id="trNotes">
        <td valign="top" class="controlarea2">
            <div id="packagesdiv" runat="server">
                <em>Packages:</em>      
                @if (Model.Packages.Count > 0)
                {
                    <table>
                    <tr>
                        <th>Shipped Date</th>
                        <th>Tracking Number</th>
                    </tr>
                    @foreach (var package in Model.Packages)
                    {
                        <tr>
                            <td>@if (!package.HasShipped)
                                { <text>Not Shipped</text>}
                                else { @package.ShipDateUtc.ToLocalTime()}</td>
                            <td>
                                @package.TrackingNumber
                            </td>
                        </tr>
                    }
                    </table>
                }  
            </div>
            <br/>
            <em>Public Notes:</em>
            @if (Model.Notes.Count > 0)
            {
                <table>
                @foreach (var note in Model.Notes)
                {
                    if (note.IsPublic)
                    {
                    <tr><td>@note.AuditDate.ToString("d")<br />
                            @note.Note</td></tr>
                    }
                }
                </table>
            }            
        </td>
        <td valign="top" class="controlarea2">
            &nbsp;
        </td>
        <td class="controlarea2" align="left" valign="top">
            <em>Payment Information:</em>
            @Html.Partial("_OrderPaymentSummary",(MerchantTribe.Commerce.Orders.OrderPaymentSummary)ViewBag.OrderPaymentSummary)            
            &nbsp;<br />            
        </td>
    </tr>
</table>
